/*
 * Copyright (c) 2011. This file is public under GPLv3 license.
 * For more information about license please refer to http://www.gnu.org/licenses/gpl.html
 */

package com.freetools.watchdog.commands;

import com.freetools.watchdog.Console;
import com.freetools.watchdog.engine.UserInformation;
import com.freetools.watchdog.model.CommandName;
import com.freetools.watchdog.model.IModelHolder;
import org.apache.log4j.Logger;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Description to be do.
 *
 * @author Michael Morozov
 */
@CommandName({"help", "h"})
public class HelpCmd extends Command
{

    private static Logger log = Logger.getLogger(HelpCmd.class);

    public void execute(IModelHolder model)
    {
        BufferedReader help = new BufferedReader(new InputStreamReader(Console.class.getResourceAsStream("readme.txt")));
        try
        {
            try
            {
                String line;
                while ((line = help.readLine()) != null) UserInformation.info(line);
            } finally
            {
                help.close();
            }
        } catch (IOException ignore)
        {
            log.error(ignore);
        }
    }
}
